home *** CD-ROM | disk | FTP | other *** search
/ Reverse Code Engineering RCE CD +sandman 2000 / ReverseCodeEngineeringRceCdsandman2000.iso / RCE / Tools / Turbo Pascal V7 / TVDEMOS.ZIP / GENRDEMO.PAS < prev    next >
Pascal/Delphi Source File  |  1992-11-03  |  9KB  |  325 lines

  1. {************************************************}
  2. {                                                }
  3. {   Turbo Vision Demo                            }
  4. {   Copyright (c) 1992 by Borland International  }
  5. {                                                }
  6. {************************************************}
  7.  
  8. { Resource generator for TVRDEMO.EXE. This program generates the
  9.   resource file that is used TVRDEMO.PAS. To build this program,
  10.   execute the batch file, MKRDEMO.BAT.
  11.  
  12.   Note: This program is designed for real-mode use only.
  13. }
  14.  
  15. program GenRDemo;
  16.  
  17. {$M 16384,8192,655360}
  18.  
  19. uses Drivers, Objects, Views, Dialogs, Menus, App, ColorSel,
  20.   StdDlg, Editors, DemoHelp, DemoCmds, DemoStrs;
  21.  
  22. { If you get a FILE NOT FOUND error when compiling this program,
  23.   use the MKRDEMO.BAT file described above.
  24. }
  25.  
  26. type
  27.   PProtectedStream = ^TProtectedStream;
  28.   TProtectedStream = object(TBufStream)
  29.     procedure Error(Code, Info: Integer); virtual;
  30.   end;
  31.  
  32. var
  33.   RezFile: TResourceFile;
  34.   RezStream: PStream;
  35.  
  36. { TProtectedStream }
  37.  
  38. procedure TProtectedStream.Error(Code, Info: Integer);
  39. begin
  40.   Writeln('Error in stream: Code = ', Code, ' Info = ', Info);
  41.   Halt(1);
  42. end;
  43.  
  44. { Resource procedures }
  45.  
  46. procedure CreateStrings;
  47. var
  48.   S: PStrListMaker;
  49. begin
  50.   S := New(PStrListMaker, Init(10000, 100));
  51.  
  52.   S^.Put(sNoMem, 'Not enough memory available to compilete operation.');
  53.   S^.Put(sErrorReading, 'Error reading file %s.');
  54.   S^.Put(sErrorWriting, 'Error writing file %s.');
  55.   S^.Put(sErrorCreating, 'Error creating file %s.');
  56.   S^.Put(sModified, '%s has been modified. Save?');
  57.   S^.Put(sSaveUntitled, 'Save untitled file?');
  58.   S^.Put(sStrNotFound, 'Search string not found.');
  59.   S^.Put(sReplace, 'Replace this occurence?');
  60.   S^.Put(sErrorHelp, 'Could not open help file.');
  61.   S^.Put(sErrorOpenDesk, 'Could not open desktop file');
  62.   S^.Put(sErrorReadingDesk, 'Error reading desktop file');
  63.   S^.Put(sDeskInvalid, 'Error: Invalid Desktop file.');
  64.   S^.Put(sErrorDeskCreate, 'Could not create TVDEMO.DSK.');
  65.  
  66.   RezFile.Put(S, 'Strings');
  67.   Dispose(S, Done);
  68. end;
  69.  
  70. procedure CreateMenu;
  71. var
  72.   R: TRect;
  73.   P: PView;
  74. begin
  75.   R.Assign(0, 0, 80, 1);
  76.   P := New(PMenuBar, Init(R, NewMenu(
  77.     NewSubMenu('~'#240'~', hcSystem, NewMenu(
  78.       NewItem('~A~bout', '', kbNoKey, cmAbout, hcSAbout,
  79.       NewLine(
  80.       NewItem('~P~uzzle', '', kbNoKey, cmPuzzle, hcSPuzzle,
  81.       NewItem('Ca~l~endar', '', kbNoKey, cmCalendar, hcSCalendar,
  82.       NewItem('Ascii ~t~able', '', kbNoKey, cmAsciiTab, hcSAsciiTable,
  83.       NewItem('~C~alculator', '', kbNoKey, cmCalculator, hcCalculator, nil))))))),
  84.     NewSubMenu('~F~ile', hcFile, NewMenu(
  85.       StdFileMenuItems(nil)),
  86.     NewSubMenu('~E~dit', hcEdit, NewMenu(
  87.       StdEditMenuItems(
  88.       NewLine(
  89.       NewItem('~S~how clipboard', '', kbNoKey, cmShowClip, hcShowClip,
  90.       nil)))),
  91.     NewSubMenu('~S~earch', hcSearch, NewMenu(
  92.       NewItem('~F~ind...', '', kbNoKey, cmFind, hcFind,
  93.       NewItem('~R~eplace...', '', kbNoKey, cmReplace, hcReplace,
  94.       NewItem('~S~earch again', '', kbNoKey, cmSearchAgain, hcSearchAgain,
  95.       nil)))),
  96.     NewSubMenu('~W~indow', hcWindows, NewMenu(
  97.       StdWindowMenuItems(nil)),
  98.     NewSubMenu('~O~ptions', hcOptions, NewMenu(
  99.       NewItem('~M~ouse...', '', kbNoKey, cmMouse, hcOMouse,
  100.       NewItem('~C~olors...', '', kbNoKey, cmColors, hcOColors,
  101.       NewLine(
  102.       NewItem('~S~ave desktop', '', kbNoKey, cmSaveDesktop, hcOSaveDesktop,
  103.       NewItem('~R~etrieve desktop', '', kbNoKey, cmRetrieveDesktop, hcORestoreDesktop, nil)))))),
  104.       nil)))))))));
  105.  
  106.   RezFile.Put(P, 'MenuBar');
  107.   Dispose(P, Done);
  108. end;
  109.  
  110. procedure CreateStatusLine;
  111. var
  112.   R: TRect;
  113.   P: PView;
  114. begin
  115.   R.Assign(0, 24, 80, 25);
  116.   P := New(PStatusLine, Init(R,
  117.     NewStatusDef(0, $FFFF,
  118.       NewStatusKey('~Alt-X~ Exit', kbAltX, cmQuit,
  119.       NewStatusKey('~F1~ Help', kbF1, cmHelp,
  120.       NewStatusKey('~F3~ Open', kbF3, cmOpen,
  121.       NewStatusKey('~Alt-F3~ Close', kbAltF3, cmClose,
  122.       NewStatusKey('~F5~ Zoom', kbF5, cmZoom,
  123.       NewStatusKey('', kbF10, cmMenu,
  124.       NewStatusKey('', kbCtrlF5, cmResize,
  125.       nil))))))),
  126.     nil)));
  127.  
  128.   RezFile.Put(P, 'StatusLine');
  129.   Dispose(P, Done);
  130. end;
  131.  
  132. procedure CreateFileOpenDialog;
  133. var
  134.   P: PView;
  135. begin
  136.   P := New(PFileDialog, Init('*.*', 'Open a File',
  137.     '~N~ame', fdOpenButton + fdHelpButton + fdNoLoadDir, 100));
  138.   P^.HelpCtx := hcFOFileOpenDBox;
  139.  
  140.   RezFile.Put(P, 'FileOpenDialog');
  141.   Dispose(P, Done);
  142. end;
  143.  
  144. procedure CreateAboutDialog;
  145. var
  146.   R: TRect;
  147.   D: PDialog;
  148. begin
  149.   R.Assign(0, 0, 40, 11);
  150.   D := New(PDialog, Init(R, 'About'));
  151.   with D^ do
  152.   begin
  153.     Options := Options or ofCentered;
  154.  
  155.     R.Grow(-1, -1);
  156.     Dec(R.B.Y, 3);
  157.     Insert(New(PStaticText, Init(R,
  158.       #13 +
  159.       ^C'Turbo Vision Demo'#13 +
  160.       #13 +
  161.       ^C'Copyright (c) 1992'#13 +
  162.       #13 +
  163.       ^C'Borland International')));
  164.  
  165.     R.Assign(15, 8, 25, 10);
  166.     Insert(New(PButton, Init(R, 'O~K', cmOk, bfDefault)));
  167.   end;
  168.  
  169.   RezFile.Put(D, 'AboutDialog');
  170.   Dispose(D, Done);
  171. end;
  172.  
  173. procedure CreateColorSelDialog;
  174. var
  175.   R: TRect;
  176.   D: PDialog;
  177. begin
  178.   D := New(PColorDialog, Init('',
  179.     ColorGroup('Desktop',       DesktopColorItems(nil),
  180.     ColorGroup('Menus',         MenuColorItems(nil),
  181.     ColorGroup('Dialogs/Calc',  DialogColorItems(dpGrayDialog, nil),
  182.     ColorGroup('Editor/Puzzle', WindowColorItems(wpBlueWindow, nil),
  183.     ColorGroup('Ascii table',   WindowColorItems(wpGrayWindow, nil),
  184.     ColorGroup('Calendar',
  185.       WindowColorItems(wpCyanWindow,
  186.       ColorItem('Current day',       22, nil)),
  187.       nil))))))));
  188.   D^.HelpCtx := hcOCColorsDBox;
  189.  
  190.   RezFile.Put(D, 'ColorSelectDialog');
  191.   Dispose(D, Done);
  192. end;
  193.  
  194. procedure CreateChDirDialog;
  195. var
  196.   R: TRect;
  197.   D: PDialog;
  198. begin
  199.   D := New(PChDirDialog, Init(cdNormal + cdHelpButton + cdNoLoadDir, 101));
  200.   D^.HelpCtx := hcFCChDirDBox;
  201.  
  202.   RezFile.Put(D, 'ChDirDialog');
  203.   Dispose(D, Done);
  204. end;
  205.  
  206. procedure CreateFindDialog;
  207. var
  208.   D: PDialog;
  209.   Control: PView;
  210.   R: TRect;
  211. begin
  212.   R.Assign(0, 0, 38, 12);
  213.   D := New(PDialog, Init(R, 'Find'));
  214.   with D^ do
  215.   begin
  216.     Options := Options or ofCentered;
  217.  
  218.     R.Assign(3, 3, 32, 4);
  219.     Control := New(PInputLine, Init(R, 80));
  220.     Insert(Control);
  221.     R.Assign(2, 2, 15, 3);
  222.     Insert(New(PLabel, Init(R, '~T~ext to find', Control)));
  223.     R.Assign(32, 3, 35, 4);
  224.     Insert(New(PHistory, Init(R, PInputLine(Control), 10)));
  225.  
  226.     R.Assign(3, 5, 35, 7);
  227.     Insert(New(PCheckBoxes, Init(R,
  228.       NewSItem('~C~ase sensitive',
  229.       NewSItem('~W~hole words only', nil)))));
  230.  
  231.     R.Assign(14, 9, 24, 11);
  232.     Insert(New(PButton, Init(R, 'O~K~', cmOk, bfDefault)));
  233.     Inc(R.A.X, 12); Inc(R.B.X, 12);
  234.     Insert(New(PButton, Init(R, 'Cancel', cmCancel, bfNormal)));
  235.  
  236.     SelectNext(False);
  237.   end;
  238.  
  239.   RezFile.Put(D, 'FindDialog');
  240.   Dispose(D, Done);
  241. end;
  242.  
  243. procedure CreateReplaceDialog;
  244. var
  245.   D: PDialog;
  246.   Control: PView;
  247.   R: TRect;
  248. begin
  249.   R.Assign(0, 0, 40, 16);
  250.   D := New(PDialog, Init(R, 'Replace'));
  251.   with D^ do
  252.   begin
  253.     Options := Options or ofCentered;
  254.  
  255.     R.Assign(3, 3, 34, 4);
  256.     Control := New(PInputLine, Init(R, 80));
  257.     Insert(Control);
  258.     R.Assign(2, 2, 15, 3);
  259.     Insert(New(PLabel, Init(R, '~T~ext to find', Control)));
  260.     R.Assign(34, 3, 37, 4);
  261.     Insert(New(PHistory, Init(R, PInputLine(Control), 10)));
  262.  
  263.     R.Assign(3, 6, 34, 7);
  264.     Control := New(PInputLine, Init(R, 80));
  265.     Insert(Control);
  266.     R.Assign(2, 5, 12, 6);
  267.     Insert(New(PLabel, Init(R, '~N~ew text', Control)));
  268.     R.Assign(34, 6, 37, 7);
  269.     Insert(New(PHistory, Init(R, PInputLine(Control), 11)));
  270.  
  271.     R.Assign(3, 8, 37, 12);
  272.     Insert(New(PCheckBoxes, Init(R,
  273.       NewSItem('~C~ase sensitive',
  274.       NewSItem('~W~hole words only',
  275.       NewSItem('~P~rompt on replace',
  276.       NewSItem('~R~eplace all', nil)))))));
  277.  
  278.     R.Assign(17, 13, 27, 15);
  279.     Insert(New(PButton, Init(R, 'O~K~', cmOk, bfDefault)));
  280.     R.Assign(28, 13, 38, 15);
  281.     Insert(New(PButton, Init(R, 'Cancel', cmCancel, bfNormal)));
  282.  
  283.     SelectNext(False);
  284.   end;
  285.  
  286.   RezFile.Put(D, 'ReplaceDialog');
  287.   Dispose(D, Done);
  288. end;
  289.  
  290. procedure CreateSaveAsDialog;
  291. var
  292.   D: PDialog;
  293. begin
  294.   D := New(PFileDialog, Init('*.*', 'Save file as', '~N~ame',
  295.     fdOkButton + fdHelpButton + fdNoLoadDir, 101));
  296.   RezFile.Put(D, 'SaveAsDialog');
  297.   Dispose(D, Done);
  298. end;
  299.  
  300. begin
  301.   RezStream := New(PProtectedStream, Init('TVRDEMO.TVR', stCreate, 4096));
  302.   RezFile.Init(RezStream);
  303.  
  304.   RegisterObjects;
  305.   RegisterType(RStrListMaker);
  306.   RegisterViews;
  307.   RegisterMenus;
  308.   RegisterDialogs;
  309.   RegisterStdDlg;
  310.   RegisterColorSel;
  311.  
  312.   CreateStrings;
  313.   CreateMenu;
  314.   CreateStatusLine;
  315.   CreateFileOpenDialog;
  316.   CreateAboutDialog;
  317.   CreateColorSelDialog;
  318.   CreateChDirDialog;
  319.   CreateFindDialog;
  320.   CreateReplaceDialog;
  321.   CreateSaveAsDialog;
  322.  
  323.   RezFile.Done;
  324. end.
  325.